<?php
include("../conn.php");
	     $pdo = getConn();
		 $sql = "select * from articles";
	     $stmt = $pdo ->prepare($sql);
	     $stmt->execute();
		 $articles = $stmt->fetchAll();

?>
<!DOCTYPE html>
<html lang="zh">
<head>
	<meta charset="UTF-8">
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
	<meta http-equiv="X-UA-Compatible" content="ie=edge">
	<meta charset="utf-8">
	<meta name="viewport" content="width=device-width, initial-scale=1">
	<meta name="description" content="">
	<meta name="author" content="Mark Otto, Jacob Thornton, and Bootstrap contributors">
	<meta name="generator" content="Hugo 0.88.1">
	<title></title>
	<link rel="stylesheet" type="text/css" href="bootstrap.min.css"/>
	    <!-- Favicons -->
	<link rel="apple-touch-icon" href="/docs/5.1/assets/img/favicons/apple-touch-icon.png" sizes="180x180">
	<link rel="icon" href="/docs/5.1/assets/img/favicons/favicon-32x32.png" sizes="32x32" type="image/png">
	<link rel="icon" href="/docs/5.1/assets/img/favicons/favicon-16x16.png" sizes="16x16" type="image/png">
	<link rel="manifest" href="/docs/5.1/assets/img/favicons/manifest.json">
	<link rel="mask-icon" href="/docs/5.1/assets/img/favicons/safari-pinned-tab.svg" color="#7952b3">
	<link rel="icon" href="/docs/5.1/assets/img/favicons/favicon.ico">
	<meta name="theme-color" content="#7952b3">
	    <style>
	      .bd-placeholder-img {
	        font-size: 1.125rem;
	        text-anchor: middle;
	        -webkit-user-select: none;
	        -moz-user-select: none;
	        user-select: none;
	      }
	
	      @media (min-width: 768px) {
	        .bd-placeholder-img-lg {
	          font-size: 3.5rem;
	        }
	      }
	    </style>
	
	    
	    <!-- Custom styles for this template -->
	    <link href="dashboard.css" rel="stylesheet">
</head>
<body>
	<header class="navbar navbar-dark sticky-top bg-dark flex-md-nowrap p-0 shadow">
	  <a class="navbar-brand col-md-3 col-lg-2 me-0 px-3" href="#">后台管理</a>
	  <button class="navbar-toggler position-absolute d-md-none collapsed" type="button" data-bs-toggle="collapse" data-bs-target="#sidebarMenu" aria-controls="sidebarMenu" aria-expanded="false" aria-label="Toggle navigation">
	    <span class="navbar-toggler-icon"></span>
	  </button>
	  <input class="form-control form-control-dark w-100" type="text" placeholder="搜索" aria-label="Search">
	  <div class="navbar-nav">
	    <div class="nav-item text-nowrap">
	      <a class="nav-link px-3" href="#">退出登录</a>
	    </div>
	  </div>
	</header>
	
	<div class="container-fluid">
	  <div class="row">
	    <nav id="sidebarMenu" class="col-md-3 col-lg-2 d-md-block bg-light sidebar collapse">
	      <div class="position-sticky pt-3">
	        <ul class="nav flex-column">
	          <li class="nav-item">
	            <a class="nav-link active" aria-current="page" href="#">
	              <span data-feather="home"></span>
	              文章列表
	            </a>
	          </li>
	          <li class="nav-item">
	            <a class="nav-link" href="#">
	              <span data-feather="file"></span>
				  <a href="../admin/add.php">添加文章</a>
	            </a>
	        </ul>
	      </div>
	    </nav>
	
	    <main class="col-md-9 ms-sm-auto col-lg-10 px-md-4">
	      <div class="d-flex justify-content-between flex-wrap flex-md-nowrap align-items-center pt-3 pb-2 mb-3 border-bottom">
	        <h1 class="h2">博客列表</h1>
	      </div>
		  <table class="table">
		    <thead>
		      <tr>
		        <th scope="col">#</th>
		        <th scope="col">First</th>
		        <th scope="col">Last</th>
		        <th scope="col">Handle</th>
		      </tr>
		    </thead>
		    <tbody>
		      <tr>
		        <th scope="row">1</th>
		        <td>Mark</td>
		        <td>Otto</td>
		        <td>@mdo</td>
		      </tr>
		      <tr>
		        <th scope="row">2</th>
		        <td>Jacob</td>
		        <td>Thornton</td>
		        <td>@fat</td>
		      </tr>
		      <tr>
		        <th scope="row">3</th>
		        <td colspan="2">Larry the Bird</td>
		        <td>@twitter</td>
		      </tr>
		    </tbody>
		  </table>
	  </div>
	</div>
	<script src="https://cdn.bootcdn.net/ajax/libs/twitter-bootstrap/5.0.2/js/bootstrap.bundle.min.js"></script>
	      <script src="feather.min.js" integrity="sha384-uO3SXW5IuS1ZpFPKugNNWqTZRRglnUJK6UAZ/gxOX80nxEkN9NcGZTftn6RzhGWE" crossorigin="anonymous"></script><script src="Chart.min.js" integrity="sha384-zNy6FEbO50N+Cg5wap8IKA4M/ZnLJgzc6w2NqACZaK0u0FXfOWRRJOnQtpZun8ha" crossorigin="anonymous"></script><script src="dashboard.js"></script>
	</ul>
	<?php
	foreach($articles as $article) {
	?>
	<li><a href="/blog.php?id=<?=$article['id']?>">
	<?php
	echo $article['title'];
	?>
	</a>  
	
	<?=$article['ctime']?>
	</li>
	<?php 
	}
	?>
</body>
</html>